home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
C64
/
T-TPUG Old Monthly Disks
/
(c)t6.d64
/
sound setter.c
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2007-02-04
|
3KB
|
101 lines
1 REM....... SOUND SETTER ...........
2 REM C-64 SOUND SETTING PROGRAM.....
3 REM USES VOICE 1
5 DIM EN(16)
10 DATA 2,8,16,24,38,56,68,80,100,250,500,800,1000,3000,5000,8000
12 FOR I=1TO16:READ EN(I):NEXT
20 PRINT"[147]":V1=54272:FORI=V1TOV1+24:POKE I,0:NEXT:REM CLEAR SID CHIP..
30 INPUT"WAVEFORM TRI-SAW-NOISE-PULSE";WA$
31 :
45 INPUT"FREQUENCY 0-4000HZ";FR
46 VA=FR/.0596:IF VA>65535THEN VA=65535
50 FLO=VA-65280:IF FLO<0THEN FLO=0
60 FHI=VA/256:POKEV1+1,FHI:POKEV1,FLO
61 :
62 IF WA$<>"PULSE"THEN 70
63 INPUT"ENTER PULSE DUTY CYCLE %";DC:IFDC<0ORDC>100 THEN DC=0
64 PN=DC*40.95:PL=PNAND255:PH=(PNAND3840)/255
65 POKE54274,PL:POKE54275,PH
70 PRINT"VALID ATTACK/SUSTAIN VALUES"
71 FORI=1TO16:PRINT EN(I);:NEXT:PRINT
72 PRINT"VALID DECAY/RELEASE VALUES"
73 FORI=1TO16:PRINT EN(I)*3;:NEXT:PRINT
75 INPUT"ATTACK VALUE(MSEC)";AT:GOSUB 400:IFAT=-1THEN75
80 INPUT"DECAY VALUE (MSEC)";DE:GOSUB 500:IFDE=-1THEN80
85 INPUT"SUSTAIN VALUE(MSEC)";SU:GOSUB 600:IFSU=-1THEN85
90 INPUT"RELEASE VALUE(MSEC)";RE:GOSUB 700:IFRE=-1THEN90
91 :
100 FI=0:INPUT"IS FILTERING DESIRED Y/N";A$:IF A$<>"Y" THEN GOTO125
102 POKEV1+23,241:REM TURN ON VOICE-1 FILTER.
105 INPUT"LO-PASS Y/N";F1$
110 INPUT"HI-PASS Y/N";F2$
115 INPUT"BAND-PASS Y/N";F3$
120 GOSUB 800
125 POKEV1+24,FI+15:REM SET VOL TO MAX
180 :
195 IFWA$="TRI"THEN PV=17
196 IFWA$="SAW"THEN PV=33
197 IFWA$="NOISE"THEN PV=129
198 IFWA$="PULSE"THEN PV=65
200 PRINT"[147] SELECTED SOUND PARAMETERS "
202 PRINT"FREQUENCY-";FR;"HZ WAVEFORM-"WA$
204 PRINT"ATTACK-"AT" MSEC DECAY-"DE"MSEC"
205 PRINT"SUSTAIN-"SU"MSEC RELEASE-"RE"MSEC
206 [139]WA$[178]"PULSE"[167] [153][199](13);"PULSE DUTY CYCLE-";DC;"%"
208 [153]"HIT (SPACE) TO PLAY NOTE"[199](13)" F1 TO RE-SET..."
220 [161]A$:[139]A$[178][199](133)[167]20
225 [139]A$[179][177][199](32)[167]220
230 [143] PLAY NOTE............
233 [151] V1[170]4,PV:[143] TURN ON SOUND
234 [143]******FOR W=1TO(AT+DE+SU):NEXT
235 [151]V1[170]4,PV[171]1:[143] CLR GATE BIT.LET ENVELOPE RELEASE.
250 [137]220
260 :
400 [143]..SUB POKES ATTACK VALUE
405 [139]AT[179]2 [176] AT[177]8000 [167]420
410 [129] I[178]1[164]16
412 [139] AT[178]EN(I)[167]430
415 [130]I
420 [153]"***INVALID ATTACK VALUE***":AT[178][171]1:[137]450
430 [151]V1[170]5,(I[171]1)[172]16:[143] ATTACK CODE TO BITS 4-7
450 [142]
499 :
500 [143]...SUB POKES DECAY VALUE
505 [139]DE[179]6 [176]DE[177]24000 [167]520
510 [129] J[178]1[164]16:[139] DE[178]EN(J)[172]3 [167] 530
515 [130]J
520 [153]"*INVALID DECAY VALUE*":DE[178][171]1:[137]550
530 [151]V1[170]5,J[171]1:[143] DECAY CODE BIT 0-3
550 [142]
599 :
600 [143]..SUB POKES SUSTAIN VALUE
605 [139]SU[179]2 [176] SU[177]8000 [167]620
610 [129] K[178]1[164]16
612 [139] SU[178]EN(K)[167]630
615 [130]K
620 [153]"***INVALID SUSTAIN VALUE***":SU[178][171]1:[137]650
630 [151]V1[170]6,(K[171]1)[172]16:[143] SUSTAIN CODE TO BITS 4-7
650 [142]
699 :
700 [143]...SUB POKES RELEASE VALUE
705 [139]DE[179]6 [176]DE[177]24000 [167]720
710 [129] L[178]1[164]16:[139] RE[178]EN(L)[172]3 [167] 730
715 [130]L
720 [153]"*INVALID RELEASE VALUE*":RE[178][171]1:[137]750
730 [151]V1[170]6,L[171]1:[143] RELEASE CODE BIT 0-3
750 [142]
751 :
800 [143] SET UP FILTER(S)
802 FI[178]0
810 [133]"ENTER CUTOFF FREQ-HZ";CF
812 [141]850:[151]V1[170]21,FCL:[151]V1[170]22,FCH
815 [139]F1$[178]"Y" [167] FI[178]FI[170]16
816 [139]F2$[178]"Y" [167] FI[178]FI[170]64
817 [139]F3$[178]"Y" [167] FI[178]FI[170]32
820 [142]
821 :
849 [143] CALCULATE & RETURN FILTER REGISTER VALUE.
850 RV[178][182](CF[171]30)[173]5.85:[139]RV[177]2047 [167]RV[178]2047
855 FCL[178]RV[175]7:FCH[178]RV[173]8
860 [142]